﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using OutlookHub.Utils;
using System.Drawing;
using Silvermoon.Images;
using Silvermoon.Windows;
using Silvermoon.OpenGL;

namespace OutlookHub.Classes
{
    /// <summary>
    /// Item with text and a number in a read circle which contains the number of emails or unread emails.
    /// </summary>
    public class MailFolderItem : ContainerItem
    {
        private int count;
        private Label textLabel;
        private Label numberLabel;

        public MailFolderItem()
            : base()
        {
            textLabel = new Label { Font = FontPool.MediumRegularFont, AutoSize = true, Margin = new Margin(0, 2, null, null) };
            numberLabel = new Label { Size = new Size(32, 32), Background = SysImages.RadioBackground, Alignment = Alignment.Center, LineAlignment = Alignment.Center, Margin = new Margin(0, 2, null, null), TextColor = PhoneColors.White, FontScale = 0.6f, Visible = false };
            numberLabel.Background.Color = PhoneColors.Red;
            StackPanel sp = new StackPanel { FillControlIndex = 0, Orientation = StackPanelOrientation.Horizontal, Margin = Margin.Zero, Height = 80 };
            sp.Controls.Add(textLabel, numberLabel);
            Control = sp;
        }

        public string Text
        {
            get { return textLabel.Text; }
            set { textLabel.Text = value; }
        }

        public int Count
        {
            get { return count; }
            set
            {
                count = value;
                if (value <= 99)
                {
                    numberLabel.Text = value.ToString();
                }
                else
                {
                    numberLabel.Text = "++";
                }
                numberLabel.Visible = count > 0;
            }
        }
    }
}
